import { findHeadCategory } from '@/api/home'

export default {
  namespaced: true,
  state: () => ({
    list: [] // 分类列表
  }),
  mutations: {
    setList (state, list) {
      state.list = list
    }
  },
  actions: {
    async asyncSetList (ctx) {
      // 1.调用接口方法
      // 2.成功获取到数据之后触发setList mutation函数
      const res = await findHeadCategory()
      console.log(res.data.result)
      ctx.commit('setList', res.data.result)
    }
  }
}
